<html>
<head>
<meta charset="UTF-8">
<title>定时调度配置修改</title>
<link href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<link href="../../static/css/esaas-easyui-edit.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.ext.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout" scroll="no">
	<form id="ff" method="post">
		<div class="esaas-info-title">定时调度配置信息</div>
		<table class="esaas-info-edit-table">
			<tr>
				<td width="15%" align="right">定时作业编号：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="jobCode" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">定时作业描述：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="jobDesc" data-options="required:false"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">执行节点标识：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="agentId" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">Cron表达式：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="cronExpression" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				
			</tr>
			<tr>
				<td width="15%" align="right">作业类类型：</td>
				<td width="35%"><select class="easyui-combobox"
					id="jobClassType" name="jobClassType"
					style="width: 100%; height: 25px;"
					data-options="required:true,editable:false,valueField:'enname',textField:'cnname',data:JOB_CLASS_TYPE, onSelect: onChangeJobType">
				</select></td>
				<td width="15%" align="right">作业实现类：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="jobClass" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				
			</tr>
			<tr>
				<td width="15%" align="right">作业类方法：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="jobMethod" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right"><span id="serviceVersionLabel">服务版本：</span></td>
				<td width="35%"><input class="easyui-textbox" type="text" id="serviceVersion"
					name="serviceVersion" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				
			</tr>
			<tr>
				<td width="15%" align="right"><span id="serviceGroupLabel">服务组别：</span></td>
				<td width="35%"><input class="easyui-textbox" type="text" id="serviceGroup"
					name="serviceGroup" data-options="required:false"
					style="width: 100%; height: 25px;"></input></td>
				<td width="18%" align="right"><span id="serviceTimeoutLabel">服务超时时间(毫秒)：</span></td>
				<td width="35%"><input class="easyui-textbox" type="text" id="serviceTimeout"
					name="serviceTimeout" data-options="required:false"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">失败重试次数：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="againTime" data-options="required:true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">重试间隔秒数：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="retrySecond" data-options="required:false"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">备注：</td>
				<td width="85%" colspan="3"><input class="easyui-textbox" type="text"
					name="remark" data-options="required:false, multiline: true"
					style="width: 100%; height: 50px;"></input></td>
			</tr>
		</table>
	</form>
	<div class="esaas-info-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton " iconCls="icon-ok" onclick="submitForm()" style="width:90px">&nbsp;保&nbsp;存&nbsp;</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeForm()" style="width:90px">&nbsp;关&nbsp;闭&nbsp;</a>
	</div>
	<script>		
		$(function() {
		    addTitle("修改");

			var jobCode = $.getUrlParam('jobCode');
			$.restfulGet('../../api/s/srvs/cron/conf/' + jobCode,null,function(data){
					$('#ff').form('load', {
						jobCode : data.rows.jobCode,
						jobDesc : data.rows.jobDesc,
						jobClassType : data.rows.jobClassType,
						jobClass : data.rows.jobClass,
						jobMethod : data.rows.jobMethod,
						serviceVersion : data.rows.serviceVersion,
						serviceGroup : data.rows.serviceGroup,
						serviceTimeout : data.rows.serviceTimeout,
						cronExpression : data.rows.cronExpression,
						againTime : data.rows.againTime,
						retrySecond : data.rows.retrySecond,
						agentId : data.rows.agentId,
						remark : data.rows.remark
					});		
					
					onChangeJobType({enname: data.rows.jobClassType})
			});
		});
	
		function submitForm() {
			if (!$('#ff').form('validate'))
				return;
			var jsonData = $("#ff").serializeJson();
			$.restfulPut('../../api/s/srvs/cron/conf', jsonData, function(data) {
				window.parent.reloadList();
			});
		};
		
		function onChangeJobType(data){
			if(data && (data.enname == 'hsf' || data.enname == 'dubbo')) {
				$("#serviceVersionLabel").show();
				$("#serviceVersion").textbox('show');
				$("#serviceGroupLabel").show();
				$("#serviceGroup").textbox('show');
				$("#serviceTimeoutLabel").show();
				$("#serviceTimeout").textbox('show');
				
				$("#serviceVersion").textbox('setRequired', true);
			} else {
			    $("#serviceVersionLabel").hide();
				$("#serviceVersion").textbox('hide');
				$("#serviceGroupLabel").hide();
				$("#serviceGroup").textbox('hide');
				$("#serviceTimeoutLabel").hide();
				$("#serviceTimeout").textbox('hide');
				
				$("#serviceVersion").textbox('setRequired', false);
				$("#serviceVersion").textbox('setValue', '');
				$("#serviceGroup").textbox('setValue', '');
				$("#serviceTimeout").textbox('setValue', '');
			}
		}
		
		
		function closeForm(){
			window.parent.JLEUtil.closewin();
		}
	</script>
</body>
</html>
